package Niuke;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class testPool {
    private static  int test=0;
    private static Object o=new Object();
    public static class mythread implements Runnable{
        @Override
        public void run() {
            synchronized (o) {
                for (int i = 0; i < 10000; i++) {
                    testPool.test++;
                }
            }
        }
    }
    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor e;
        e = new ThreadPoolExecutor(2,
                5,
                1,
                TimeUnit.MINUTES,
                new ArrayBlockingQueue<>(10));
        mythread t1=new mythread();
        mythread t2=new mythread();
        e.execute(t1);
        Thread.sleep(1000);
        e.shutdown();
        System.out.println(testPool.test);
    }

}
